<?php
/**
 * Created by PhpStorm.
 * User: Ysll <754060604@qq.com>
 * Date: 2017/10/10
 * Time: 11:20
 */

namespace Admin\Model;


class Model extends \Think\Model
{
    /**
     * 获取实例
     *
     * @return \Think\Model
     */
    public static function getInstance()
    {
        return new static();
    }

    /**
     * 根据id查找数据
     *
     * @param $id
     * @return mixed
     */
    public static function findById($id)
    {
        return self::getInstance()->where('id = '. $id)->find();
    }

    /**
     * 删除数据
     *
     * @param $id
     * @return mixed
     */
    public static function destroy($id)
    {
        return self::getInstance()->where('id = ' . $id)->delete();
    }

    /**
     * 更新数据
     *
     * @param int $id
     * @param array $data
     * @return bool|null
     */
    public static function update($id, array $data)
    {
        $data['updated_at'] = date('Y-m-d H:i:s');
        return self::getInstance()->where('id = ' . $id)->save($data);
    }
}